<!-- Student_dailyCheckNew.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" >
		<title>学生端签到页</title>
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/CFNetPP_Base.css">
		<link rel="stylesheet" type="text/css" href="../../css/timecontrol.min.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
		<style type="text/css">
			.content-div{
				background-color: white;
			}
			p{
				margin-bottom: 0;
			}
			.time-title{
				font-size: 48px;
				line-height: 1em;
				text-align: center;
				margin-bottom: 0;
			}
			.top-content-div{
				padding: 14px 0;
				text-align: center;
			}
			.position-icon{
				height: 20px;
				position: relative;
				top: 4px;
			}
			.position-title{
				font-size: 14px;
				line-height: 25px;
				color: #999;
				word-break:break-all;
				margin-bottom: 0;
			}
			.mood-div{
			}
			.mood-title{
				color: #666;
				font-size: 12px;
				line-height: 1em;
				padding: 10px;
			}
			.mood-images{
				overflow:hidden;
				zoom:1;
			}
			.mood-img-div{
				width: 20%;
				float: left;
				padding: 10px;
			}
			.mood-img{
				width: 100%;
				display: block;
			}
			.mood-subtitle{
				color: #666;
				font-size: 12px;
				line-height: 1em;
				text-align: center;
				width: 100%;
			}
			.mood-radio{
				margin-top: 10px;
				width: 100%;
				height: 30px;
				text-align: center;
			}
			.mui-checkbox input[type=checkbox]:checked:before, .mui-radio input[type=radio]:checked:before{
				color: #e04d16;
			}
			.mui-checkbox input[type=checkbox], .mui-radio input[type=radio] {
			    position: unset;
			    top: unset;
			    right: unset;
			    display: inline-block;
			    width: 28px;
			    height: 28px;
			    border: 0;
			}
			.sign-btn-div{
				padding-top: 10px;
				padding-bottom: 20px;
				text-align: center;
			}
			.sign-btn{
				height: 40px;
				width: 160px;
				font-size: 16px;
				line-height: 38px;
				padding: 0;
				color: white;
				background-color: #e04d16;
				border-color: #e04d16;
				border-radius: 20px;
				font-weight: 300;
			}
			.sign-btn:active{
				color: white;
			}
			.sign-disabled-btn{
				background-color: #bcbcbc;
				border-color: #bcbcbc;
			}
			.sign-disabled-btn:active{
				background-color: #bcbcbc;
				border-color: #bcbcbc;
			}
			.fengexian{
				height: 1px;
				width: 100%;
				border-top: 1px solid #dedede;
				-webkit-transform: scaleY(.5);
			    transform: scaleY(.5);
			}
			.sign-list{
				padding: 0 0 0 10px;
			}
			.time-title-date{
				font-size: 16px;
				color: #333;
			}
			.sign-cell{
				margin-top: 10px;
			}
			.sign-cell-content-left{
				float: left;
				margin-left: 15px;
				width: 10px;
				border-left: 1px solid #dedede;
				height: 70px;
			}
			.sign-cell-content{
				padding: 10px;
				margin-left: 26px;
			}
			.sign-cell-f-content{
				padding: 10px 0;
			}
			.cell-right-div{
				float: right;
				width: 46px;
				text-align: center;
				font-size: 12px;
				line-height: 16px;
				color: #999;
			}
			.cell-left-div{
				margin-right: 46px;
				font-size: 14px;
				line-height: 16px;
				color: #666;
				font-weight: 300;
			}
			.address-title{
				color: #333;
				font-weight: 500;
			}
			.cell-content-bottom-title{
				margin-top: 4px;
			}
			.yuan-qiu{
				width: 18px;
				height: 18px;
				background-color: #e04d16;
				border-radius: 9px;
				position: relative;
				left: -9px;
				top: 25px;
			}
			.yuan-qiu-hui{
				width: 8px;
				height: 8px;
				background-color: #dedede;
				border-radius: 4px;
				position: relative;
				left: -5px;
				top: -39px;
			}
			.small-mood-icon{
				width: 20px;
				position: relative;
				top: 4px;
			}
			.bottom-zhanwei-div{
				height: 50px;
				background-color: #f3f5f7;
			}
			.bottom-more-div{
				height: 50px;
				background-color: white;
				line-height: 50px;
			}
			.bottom-more-title{
				color: #333;
				font-size: 16px;
				text-align: center;
			}
			.top-prompt{
				position: fixed;
				left: 0;
				top: -40px;
				height: 40px;
				width: 100%;
				text-align: center;
				background-color: rgba(220, 120, 20, 0.8);
				font-size: 16px;
				color: white;
			}
			#top_prompt{
				color: white;
				line-height: 40px;
				font-size: 16px;
			}
			.select-position-div{
				padding: 4px 10px;
				background-color: #f3f5f7;
			}
			.right-arrow{
				position: absolute;
				right: 10px;
				top: 10px;
				width: 18px;
			}
			.select-position-div{
				position: relative;
			}
		</style>
	</head>
	<body>
		<div id="top_prompt_div" class="top-prompt">
			<p id="top_prompt">
				您今日还未签到~
			</p>
		</div>
		<div class="content-div">
			<div class="top-content-div">
				<p id="time" class="time-title">
					00:00
				</p>
			</div>
			<div class="select-position-div" onclick="onSelectClick()">
				<div class="position-div">
					<p class="position-title">
						<img src="../../image/icon_position.png" class="position-icon">
						<span id="current_position">
							所在位置
						</span>
					</p>
				</div>
				<img class="right-arrow" src="../../image/arrow_right.png">
			</div>
			<div class="mood-div">
				<p class="mood-title">
					请根据心情进行签到呦~
				</p>
				<div class="mood-images">
					<div class="mood-img-div">
						<img class="mood-img" src="../../image/emoji_gaoxing.png">
						<span class="mood-subtitle">
							高兴
						</span>
						<div class="mood-radio mui-radio">
							<input id="mood1" name="radio1" type="radio">
						</div>
					</div>
					<div class="mood-img-div">
						<img class="mood-img" src="../../image/emoji_fennu.png">
						<span class="mood-subtitle">
							愤怒
						</span>
						<div class="mood-radio mui-radio">
							<input id="mood2" name="radio1" type="radio">
						</div>
					</div>
					<div class="mood-img-div">
						<img class="mood-img" src="../../image/emoji_youlv.png">
						<span class="mood-subtitle">
							忧虑
						</span>
						<div class="mood-radio mui-radio">
							<input id="mood3" name="radio1" type="radio">
						</div>
					</div>
					<div class="mood-img-div">
						<img class="mood-img" src="../../image/emoji_putong.png">
						<span class="mood-subtitle">
							普通
						</span>
						<div class="mood-radio mui-radio">
							<input id="mood4" name="radio1" type="radio">
						</div>
					</div>
					<div class="mood-img-div">
						<img class="mood-img" src="../../image/emoji_nanguo.png">
						<span class="mood-subtitle">
							难过
						</span>
						<div class="mood-radio mui-radio">
							<input id="mood5" name="radio1" type="radio">
						</div>
					</div>
				</div>
			</div>
			<div class="sign-btn-div">
				<div id="sign_btn" type="button" class="sign-btn mui-btn">
					签 到
				</div>
			</div>
			<div class="fengexian"></div>
			<div id="res_list" class="sign-list">
				<!-- <div class="sign-cell">
					<p class="time-title-date">
						今天
					</p>
					<div class="sign-cell-f-content">
						<div class="sign-cell-content-left">
							<span class="yuan-qiu"></span>
							<span class="yuan-qiu-hui"></span>
						</div>
						<div class="sign-cell-content">
							<div class="cell-right-div">
								09 : 54
							</div>
							<div class="cell-left-div">
								<p class="cell-content-top-title">
									已于<span class="address-title">韩国青瓦台</span>签到
								</p>
								<p class="cell-content-bottom-title">
									心情状态
									<img class="small-mood-icon" src="../../image/emoji_fennu.png">
								</p>
							</div>
						</div>
					</div>
				</div>
				<div class="sign-cell">
					<p class="time-title-date">
						昨天
					</p>
					<div class="sign-cell-f-content">
						<div class="sign-cell-content-left">
							<span class="yuan-qiu"></span>
						</div>
						<div class="sign-cell-content">
							<div class="cell-right-div">
								09 : 54
							</div>
							<div class="cell-left-div">
								<p class="cell-content-top-title">
									已于<span class="address-title">韩国青瓦台</span>签到
								</p>
								<p class="cell-content-bottom-title">
									心情状态
									<img class="small-mood-icon" src="../../image/emoji_fennu.png">
								</p>
							</div>
						</div>
					</div>
				</div> -->
			</div>
			<div class="bottom-more-div" hidden="hidden">
				<div class="fengexian"></div>
				<div class="bottom-more-title">
					查看更多签到状态
				</div>
			</div>
		</div>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 t0p_10 base_dark_grey" >
				暂无签到数据！
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="loadData()">
				重新加载
			</button>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/databaseOperation.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script type="text/javascript">
		var nowLat = 0.0;
		var nowLon = 0.0;
		var nowAddress = '';
		var page = 1;
		var time;
		var currentMood = '';
		var isShowPrompt = false;//是否提示默认不提示
		var currentIndex = 0;
		var pid;//学习计划id
		DBReady = function() {
			judgePracticeType();
			// customUI();
			SendBehaviorTrajectoriesNotifi1('0', '学生端签到', '086',api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname,  document.title);
			setupNowTime();
			setupGps(function() {
				api.showProgress({
					style : 'default',
					animationType : 'fade',
					title : '定位中...',
					text : '请稍等...',
					modal : false
				});
				getLocation(function(ret, err) {
					api.hideProgress();
					if (ret) {
						var addressArr = ret.poiList;
			    		if (addressArr != null && addressArr.constructor == Array && addressArr.length > 0) {
			    			var addressData = addressArr[0];
			    			nowAddress = addressData.city + '·' +addressData.name;
							$('#current_position').text(nowAddress);
			    		}else{
			    			api.toast({
				    		    msg: '获取位置信息失败'
				    		});
			    		}	
					}else{
						api.toast({
						    msg: '获取位置信息失败'
						});
					}
				});
			});
			setupNotifi();
		}
		function setupNotifi(){
			api.addEventListener({
			    name: 'selectLocationNotifi'
			}, function(ret, err) {
			    if (ret) {
			        var value = ret.value;
			        currentIndex = value.index;
			        nowAddress = value.address;
					$('#current_position').text(nowAddress);
			    }
			});
		}
		function onSelectClick(){
			api.openWin({useWKWebView:true,
			    name: 'Student_selectLocationAddress',
			    url: 'Student_selectLocationAddress.html',
			    pageParam: {
			        index: currentIndex
			    }
			});
		}
		//学生端获取实习计划状态（仅限学生端）
		function judgePracticeType() {
			var param = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid')
			};
			cfnetppPOST(urlPracticeType, param, true, function(data, status) {
				if (status == 'success') {
					//1,成功，返回success
					if (data.status == 1) {
						var list = data.json;
						if (list != null && list != '') {
						    pid=list.id;
							// var sxtypes = parseInt(list.sxtypes);
							// //0：顶岗，1：认知，2:跟岗
							// if (sxtypes != 1) {
							// 	$('#sign_btn').unbind('click').addClass('sign-disabled-btn');
							// }
							isShowPrompt = true;
						} else {
							ShowToast('你还未有实习计划，请等待老师分配');
						}
					} else if (data.status == -1) {
						ShowToast('你还未有实习计划，请等待老师分配');
					} else {
						ShowToast('你还未有实习计划，请等待老师分配');
					}
				}
				//加载完状态后在加载历史数据
				loadData();
			});
		}

		function setupGps(callback) {
			var bMap = api.require('bMap');
			bMap.getLocationServices(function(ret, err) {
				// alert('setupGps:'+JSON.stringify(ret)+'\n'+JSON.stringify(err));
				if (ret.enable != true) {
					if (api.systemType == 'ios') {//iOS
						api.alert({
							title : 'GPS未开启',
							msg : '请于“设置”-->“隐私”-->“定位服务”，打开定位功能',
						}, function(ret, err) {
						});
					} else {//安卓
						api.alert({
							title : 'GPS未开启',
							msg : '请于系统设置中打开GPS定位功能',
						}, function(ret, err) {
						});
					}
				}else if(ret.authorizationStatus == "notDetermined"){
					api.alert({
						title : 'APP定位授权未开启',
						msg : '请于“设置”-->“隐私”-->“定位服务”-->“长风网”-->“使用应用期间”，打开位置授权',
					}, function(ret, err) {
					});
				}else if(ret.authorizationStatus == "restricted"){
					api.alert({
						title : 'APP定位授权未开启',
						msg : '请于“设置”-->“隐私”-->“定位服务”-->“长风网”-->“使用应用期间”，打开位置授权',
					}, function(ret, err) {
					});
				}else if(ret.authorizationStatus == "denied"){
					api.alert({
						title : 'APP定位授权未开启',
						msg : '请于“设置”-->“隐私”-->“定位服务”-->“长风网”-->“使用应用期间”，打开位置授权',
					}, function(ret, err) {
					});
				}else{//定位打开
					callback();
				}
			});
		}

		//设置ui
		function customUI() {
			//读取数据库最后一条签到记录
			var sql = "select signtime from t_sign_record  where uid='" + $api.getStorage('cfnetppuid') + "' order by id desc;";
			selectSQL(sql, function(ret, err) {
				if (ret.status) {
					var signArr = ret.data;
					if (signArr.length > 0) {
						var signData = ret.data[0];
						setupSignBtn(signData.signtime);
					} else {
						setupSignBtn(0);
					}
				} else {
					setupSignBtn(0);
				}
			});
		}

		function setupSignBtn(signtime) {
			if (signtime == 0) {//数据库没记录
				$('#sign_btn').click(function() {
					onSignClick();
				});
				setupPrompt(1);
			} else {
				var nowTime = new Date().getTime();
				var oldTime = timeStampWithStr(signtime);
				if (getYYMMDD(nowTime) == getYYMMDD(oldTime)) {
					$('#sign_btn').unbind('click').addClass('sign-disabled-btn');
					setupPrompt(0);
				} else {
					$('#sign_btn').click(function() {
						onSignClick();
					});
					setupPrompt(1);
				}
			}
		}
		//设置提示框
		function setupPrompt(type){
			if (isShowPrompt == true) {
				var title = "您今日已签到~";
				if (type == 1) {
					title = "您今日还未签到~";
				}
				$("#top_prompt").text(title);
				$("#top_prompt_div").animate({
					top: "0"},
					1000, function() {
					setTimeout(function(){
						$("#top_prompt_div").animate({
							top: "-40px"},
							1000);
					}, 2000);
				});
			}
		}
		function timeStampWithStr(timeStr) {
			timeStr = timeStr.toString();
			if (timeStr.length == 10) {
				return parseInt(timeStr) * 1000;
			} else {
				return parseInt(timeStr);
			}
		}

		//点击签到
		function onSignClick() {
			if(document.getElementById("mood1").checked){
				currentMood = 1;
			}else if(document.getElementById("mood2").checked){
				currentMood = 2;
			}else if(document.getElementById("mood3").checked){
				currentMood = 3;
			}else if(document.getElementById("mood4").checked){
				currentMood = 4;
			}else if(document.getElementById("mood5").checked){
				currentMood = 5;
			}else{
				api.toast({
				    msg: '请选择心情'
				});
				return;
			}
			if (nowLat == 0.0 || nowLon == 0.0) {
				setupGps(function() {
					api.showProgress({
						style : 'default',
						animationType : 'fade',
						title : '定位中...',
						text : '请稍等...',
						modal : false
					});
					getLocation(function(ret, err) {
						// alert('getLocationcallback:'+JSON.stringify(ret)+'\n'+JSON.stringify(err));
						api.hideProgress();
						if (ret) {
							// $('.nowPos').text(ret.address);
							// nowAddress = ret.address;
							// onSign();
							var addressArr = ret.poiList;
				    		if (addressArr != null && addressArr.constructor == Array && addressArr.length > 0) {
				    			var addressData = addressArr[0];
				    			nowAddress = addressData.city + '·' +addressData.name;
								$('#current_position').text(nowAddress);
								onSign();
				    		}else{
				    			api.toast({
					    		    msg: '获取位置信息失败'
					    		});
				    		}	
						} else {
							api.toast({
								msg : '获取位置失败，请重试!'
							});
						}
					});
				});
			} else {
				onSign();
			}
		}

		//签到
		function onSign() {
			var timestamp = (Date.parse(new Date()) / 1000).toString();
			var params = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
				signtime : timestamp,
				lat : nowLat.toString(),
				lon : nowLon.toString(),
				address : nowAddress,
				mood : currentMood,
				pid:pid,
				message:'签到'
			};
			cfnetppPOST(urlSign, params, false, function(data, status) {
				SendBusinessOperationsLogNotifi('签到', '086', params, params, '', data, '签到接口', '086-01')
				if (status == 'success') {
					if (data.status == 1) {
						$('#sign_btn').unbind('click').addClass('sign-disabled-btn');
						api.toast({
							msg : '签到成功',
							duration : 2000,
							location : 'bottom'
						});
						var dbData = {
							uid : $api.getStorage('cfnetppuid'),
							jid : $api.getStorage('cfnetppjid'),
							lat : nowLat,
							lon : nowLon,
							address : nowAddress,
							signtime : timestamp,
							mood : currentMood
						};
						$('#noNet').hide();
						$('#noData').hide();
						$("#res_list").prepend(htmlStringWithName(dbData));
						// insertData('t_sign_record', dbData, function(ret, err) {
						// 	$('#noNet').hide();
						// 	$('#noData').hide();
						// 	$("#res_list").prepend(htmlStringWithName(dbData));
						// });
					} else {
						////2,你还未被分配实习,返回job
						if (data.status == 2) {
							api.toast({
								msg : '你还未被分配实习,暂无法签到!',
								duration : 2000,
								location : 'bottom'
							});
							////3,您当前不在实习期内,返回time
						}
						else if (data.status == 3) {
							api.toast({
								msg : '您当前不在实习期内,无法签到!',
								duration : 2000,
								location : 'bottom'
							});
							////4,您今日已签到,返回has
						}
						else if (data.status == 4) {
							api.toast({
								msg : '您今日已签到!',
								duration : 2000,
								location : 'bottom'
							});
						} else if (data.status == 5) {
							api.toast({
								msg : '您已处于结业状态，无需签到!',
								duration : 2000,
								location : 'bottom'
							});
						} else {
							api.toast({
								msg : '签到失败,请重试!',
								duration : 2000,
								location : 'bottom'
							});
						}
					}
				} else {
					api.toast({
						msg : '签到失败,请重试!',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		function loadData() {
			api.showProgress({
				style : 'default',
				animationType : 'fade',
				title : '数据加载中...',
				text : '请稍候...',
				modal : false
			});
			cfnetppPOST(urlSignlist, {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjid'),
				all : 1
			}, true, function(data, status) {
				api.hideProgress();
				if (status == 'success') {
					if (data.status == 1) {
						var listArr = data.json;
						if (listArr != null && listArr.constructor == Array && listArr.length > 0) {
							$('#noNet').hide();
							$('#noData').hide();
							var htmlString = '';
							for (var i = 0; listArr.length > i; i++) {
								var data = listArr[i];
								htmlString += htmlStringWithName(data);
								if (i == 0) {
									var lastsignTime = data.signtime;
									setupSignBtn(lastsignTime);
								}
							}
							$("#res_list").html(htmlString);
						} else {
							$("#res_list").html('');
							$('#noNet').hide();
							$('#noData').show();
							setupSignBtn(0);
						}
					} else {
						$("#res_list").html('');
						$('#noNet').hide();
						$('#noData').show();
						// api.toast({
						//     msg: '暂无数据！',
						//     duration: 2000,
						//     location: 'bottom'
						// });
						setupSignBtn(0);
					}
				} else {
					$("#res_list").html('');
					$('#noData').hide();
					$('#noNet').show();
					// api.toast({
					//     msg: '获取签到列表失败！',
					//     duration: 2000,
					//     location: 'bottom'
					// });
					setupSignBtn(0);
				}
			});
		}

		function htmlStringWithName(data) {
			var mood = data.mood;
			var moodIcon = 'emoji_gaoxing';
			if (mood == 1) {
				moodIcon = 'emoji_gaoxing';
			}else if(mood == 2){
				moodIcon = 'emoji_fennu';
			}else if(mood == 3){
				moodIcon = 'emoji_youlv';
			}else if(mood == 4){
				moodIcon = 'emoji_putong';
			}else if(mood == 5){
				moodIcon = 'emoji_nanguo';
			}
			return '<div dataid="'+data.id+'" class="sign-cell">'+
					'<p class="time-title-date">'+
						timeWithStamp4(data.signtime)+
					'</p>'+
					'<div class="sign-cell-f-content">'+
						'<div class="sign-cell-content-left">'+
							'<span class="yuan-qiu"></span>'+
							'<span class="yuan-qiu-hui"></span>'+
						'</div>'+
						'<div class="sign-cell-content">'+
							'<div class="cell-right-div">'+
								timeWithStamp5(data.signtime)+
							'</div>'+
							'<div class="cell-left-div">'+
								'<p class="cell-content-top-title">'+
									'已于<span class="address-title">'+data.address+'</span>签到'+
								'</p>'+
								'<p class="cell-content-bottom-title">'+
									'心情状态'+
									'<img class="small-mood-icon" src="../../image/'+moodIcon+'.png">'+
								'</p>'+
							'</div>'+
						'</div>'+
					'</div>'+
				'</div>';
			// return '<li dataid="' + data.id + '" class="mui-table-view-cell">' + '<p ><span class="point"></span>' + getCurrentDate(data.signtime) + ' ' + data.address + '</p>' + '</li>';
		}

		function setupNowTime() {
			//更新时间
			function p(s) {
				return s < 10 ? '0' + s : s;
			}

			function showTime() {
				var date = new Date();
				var hour = date.getHours();
				var minute = date.getMinutes();
				var dateStr = p(hour) + ":" + p(minute);
				$('#time').html(dateStr);
			}

			var interval = window.setInterval(showTime, 1000);
		}

		//		function getNowFormatDate(time) {
		//			var datetime;
		//			if (time.length == 10) {
		//				datetime = parseInt(time) * 1000;
		//			} else {
		//				datetime = parseInt(time);
		//			}
		//			var date = new Date(datetime);
		//			var seperator1 = "-";
		//			var seperator2 = ":";
		//			var month = date.getMonth() + 1;
		//			var strDate = date.getDate();
		//			var mm = date.getMinutes();
		//			if (month >= 1 && month <= 9) {
		//				month = "0" + month;
		//			}
		//			if (strDate >= 0 && strDate <= 9) {
		//				strDate = "0" + strDate;
		//			}
		//			if (mm >= 0 && mm <= 9) {
		//				mm = "0" + mm;
		//			}
		//			var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + mm;
		//
		//			return currentdate;
		//		}
		function getNowFormatTime(date) {
			var seperator1 = "-";
			var seperator2 = ":";
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			var mm = date.getMinutes();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			if (mm >= 0 && mm <= 9) {
				mm = "0" + mm;
			}
			var currentTime = date.getHours() + seperator2 + mm;
			return currentTime;
		}

		//获取百度地图!
		function getLocation(callback) {
			var bMap = api.require('bMap');
			bMap.getLocation({
				accuracy : '100',
				autoStop : true,
				filter : 1
			}, function(ret, err) {
				// alert('getLocation:'+JSON.stringify(ret)+'\n'+JSON.stringify(err));
				if (ret.status) {
					var lon = parseFloat(ret.lon);
					var lat = parseFloat(ret.lat);
					nowLat = lat;
					nowLon = lon;
					bMap.getNameFromCoords({
						lon : lon,
						lat : lat
					}, function(ret, err) {
						callback(ret, err);
					});
				} else {
					callback('', 'err');
				}
			});
		}

		function getLocationName(lon, lat) {
			var bMap = api.require('bMap');
			// alert('获取地理名称');
			bMap.getNameFromCoords({
				lon : lon,
				lat : lat
			}, function(ret, err) {
				//				 alert(JSON.stringify(ret) + '\n' + JSON.stringify(err));
				if (ret.status) {
					// alert(JSON.stringify(ret));
				} else {
					// alert(JSON.stringify(err));
				}
			});
		}

		function getYYMMDD(time) {
			var tempDate;
			if (time.length == 10) {
				tempDate = new Date(parseInt(time) * 1000);
			} else {
				tempDate = new Date(parseInt(time));
			}
			var y = tempDate.getFullYear();
			var m = tempDate.getMonth() + 1;
			var d = tempDate.getDate();
			return y + add0(m) + add0(d);
		}

		function add0(m) {
			return m < 10 ? '0' + m : m
		}
	</script>
</html>